﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QLabel>
#include <QTimer>
#include "Camera/CameraCommon/CameraImage_RGB32.h"
#include "Camera/CameraHikVision/CameraHikVision.h"
#include "DualCamerasDisplayWidget.h"
#include "AboutDialog.h"
#include "LampControl/LightToolBar.h"
#include "StatusBarWidget.h"
QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();
private slots:
    void showAbout();
    void saveImage(int channel);
    void openImageFile(int channel);
    void updateCameraFrame(const Qly::VideoFrame &frame);
    void updateMousePos(int ch, QPointF &p);
    void onTimeoutFrameRateCounter();//用来更新真实的 FrameRate
    void openCamera1();
    void openCamera2();
    void onCameraLost();
    void reOpenCamera1();
    void reOpenCamera2();
private:
    void setupDisplay(QSettings &settings);
    void setupCamera(QSettings &settings);
    void initToolBar();
    void defaultCompanyInfo();
    bool loadImage(int channel, QImage &image);
    bool loadImageFromFile(int channel, QString fileName);
protected:
    DualCamerasDisplayWidget * m_pCentreWidget = nullptr;
    Qly::CameraImage_RGB32 *m_pImage[2];
    Qly::CameraHikVision * m_pCamera[2];
    QString m_cameraID[2];
    QString m_saveImagePath[2];
    QString m_loadImagePath[2];
    QString m_logImagePath[2];
    QString m_recipePath[2];
    double m_scale[2];
private:
    Ui::MainWindow *ui;

    AboutDialog *m_aboutDialog = nullptr;
    LightToolBar *m_pLightToolBar = nullptr;
    StatusBarWidget * m_pStatusBarWidget[2] = {nullptr, nullptr};
    QTimer * m_timerStatusBar = nullptr;
    /// 以下是公司信息，在派生类里会设置这些内容
    QString m_appName;
    QString m_companyName;
    QString m_author;
    QString m_website;
    QString m_email;
    QString m_version;
    QString m_phoneNumber;
    QIcon m_appIcon;
};





#endif // MAINWINDOW_H
